package com.web.kdl.controller;

import com.web.kdl.common.result.CommonResult;
import com.web.kdl.component.WebSocketService;
import com.web.kdl.pojo.Vo.FlyWheelData;
import com.web.kdl.pojo.Vo.FlywheelInfoVo;
import com.web.kdl.pojo.dto.FlywheelInfoDTo;
import com.web.kdl.pojo.dto.SiteDto;
import com.web.kdl.service.flywheel.FlyWheelService;
import com.web.kdl.service.report.Report1Service;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author： shulibin
 * @Date： 2025/9/22 16:42
 */
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {
    @Autowired
    Report1Service report1Service;
    @Autowired
    WebSocketService webSocketService;
    @Autowired
    FlyWheelService flyWheelService;
    @PostMapping("/message")
    public void message(String siteName) {
        SiteDto dto = new SiteDto(siteName);
        CommonResult siteBaseInfo = report1Service.getSiteBaseInfo(dto);
        webSocketService.sendTextMsg("/response/"+siteName+"/getSiteBaseInfo",siteBaseInfo);
    }
    @PostMapping("/message2")
    public void message2() {
        FlywheelInfoDTo flywheelInfoDTo = new FlywheelInfoDTo();
        flywheelInfoDTo.setSumSite("唐山站");
        flywheelInfoDTo.setFlyWheelName("flywheel1");
        flywheelInfoDTo.setMatrixName("mianyang2");
        Map<String, FlyWheelData> flywheelVo =flyWheelService.getLastValue(flywheelInfoDTo);
        webSocketService.sendTextMsg("/response/getLastValue/唐山站/mianyang2/flywheel1",flywheelVo);
    }
}
